class TipBarGui extends Gui {

  w := 120, h := 26

  __New() {
    super.__New('+AlwaysOnTop -Caption +ToolWindow +E0x00080000', Meta.name 'ToolGUI')
    this.borderPen := Gdip_CreatePen('0xff01ffe1', 1) ; 边框大小和颜色
    this.brush := Gdip_BrushCreateSolid('0x5f000000')
    this.Show()
  }

  Destroy() {
    Gdip_DeletePen(this.borderPen)
    Gdip_DeleteBrush(this.brush)
    super.Destroy()
  }

  Adapt(wx, wy) {
    this.Move(wx, wy < this.h ? wy : wy - this.h)
    return this
  }

  DrawFrame(t) {
    local w := this.w, h := this.h

    hdc := CreateCompatibleDC()
    hbm := CreateDIBSection(w, h)
    obm := SelectObject(hdc, hbm)
    G := Gdip_GraphicsFromHDC(hdc)

    Gdip_DrawRectangle(G, this.borderPen, 1, 1, w - 2, h - 2)
    Gdip_FillRectangle(G, this.brush, 0, 0, w, h)
    Gdip_TextToGraphics(G, t,
      Format('x{} y{} c{} w{} Centre Left r5 s18 {}', 0, 2, 'fff6fff1', w),
      , w, 20
    )
    this.GetPos(&x, &y)
    UpdateLayeredWindow(this.Hwnd, hdc, x, y, w, h)
    SelectObject(hdc, obm)
    DeleteObject(hbm)
    DeleteDC(hdc)
    Gdip_DeleteGraphics(G)
  }
}